IF player = "X" THEN "SAY /NOTICE "channel" Awaiting "player1name"'s Coordinates."
IF player = "O" THEN "SAY /NOTICE "channel" Awaiting "player2name"'s Coordinates."
current = "X"
DO UNTIL current = " "
coords = true
DO UNTIL LEFT(rest,4) = ":!GO"
drop rest
drop dest
drop prefix
'getline'
rest = UPPER(line.rest)
dest = line.dest
prefix = line.prefix
END
DO loop = 1 TO LENGTH(prefix)
char = RIGHT(LEFT(prefix,loop),1)
IF char = "!" THEN LEAVE
END
loop = loop - 1
nick = LEFT(prefix,loop)
IF nick = player1name | nick = player2name THEN
DO
pos = RIGHT(rest,1)
IF C2D(pos) < 49 | C2D(pos) > 57 | LENGTH(rest) > 5 THEN
DO
coords = false
'SAY /NOTICE 'channel' 'nick', Coordinate not recognised.'
END
IF nick = player2name & player = "X" | nick = player1name & player = "O" THEN
DO
"SAY /NOTICE "channel" Hey "nick", it isn't your turn yet! :)"
coords = false
END
END
ELSE
DO
coords = false
'SAY /NOTICE 'channel' 'nick', Sorry, you are not involved in this game.'
END
IF coords = true THEN
DO
pos = pos - 1
current = RIGHT(LEFT(board,pos+1),1)
IF current ~= " " THEN
DO
"SAY /NOTICE "channel" Illegal Move: Piece already present in that square!"
END
END
END
leftboard = LEFT(board,pos)
rightboard = RIGHT(board,LENGTH(board)-pos-1)
board = leftboard''player''rightboard
IF player = "O" THEN
player = "X"
else
player = "O"
END
nextplayer1 = ""
nextplayer2 = ""
'SAY /NOTICE 'channel' Would either of you like to have another go? !YES or !NO'
DO UNTIL nextplayer1 ~= "" & nextplayer2 ~= ""
DO UNTIL rest = ":!YES" | rest = ":!NO"
drop rest
drop prefix
drop dest
'getline'
rest = UPPER(line.rest)
prefix = line.prefix
dest = line.dest
END
DO loop = 1 TO LENGTH(prefix)
char = RIGHT(LEFT(prefix,loop),1)
IF char = "!" THEN LEAVE
END
loop = loop - 1
nick = LEFT(prefix,loop)
IF rest = ":!YES" THEN
DO
IF nick = player1name | nick = player2name THEN
DO
"SAY /NOTICE "channel" Good choice "nick"! your name has been put forward for the next game."
IF nick = player1name THEN
DO
nextplayer1 = nick
IF nextplayer2 = "" THEN "SAY /NOTICE "channel" What about you "player2name"? !YES or !NO ??"
END
ELSE
DO
nextplayer2 = nick
IF nextplayer1 = "" THEN "SAY /NOTICE "channel" What about you "player1name"? !YES or !NO ??"
END
END
ELSE
DO
"SAY /NOTICE "channel" Sorry "nick", you were not involved in the last game, if one of the current players uses !NO to leave the game, you will have a chance you join with the !ME command."
END
END
IF rest = ":!NO" THEN
DO
IF nick = player1name | nick = player2name THEN
DO
"SAY /NOTICE "channel" Aww, ok "nick", you will not be in the next game."
IF nick = player1name THEN
DO
nextplayer1 = "#"
IF nextplayer2 = "" THEN "SAY /NOTICE "channel" What about you "player2name"? !YES or !NO ??"
END
ELSE
DO
nextplayer2 = "#"
IF nextplayer1 = "" THEN "SAY /NOTICE "channel" What about you "player1name"? !YES or !NO ??"
END
END
ELSE
DO
"SAY /NOTICE "channel" "nick", you were not involved in this game, if you object to this game, argue with Andy! ;)"
END
END
END
IF nextplayer1 = "#" THEN nextplayer1 = ""
IF nextplayer2 = "#" THEN nextplayer2 = ""
IF nextplayer1 = "" & nextplayer2 = "" THEN
DO
"SAY /NOTICE "channel" Both players dropped out."
"SAY /NOTICE "channel" GAME OVER!!"
"SAY /NOTICE "channel" Please send comments to andrew.ricketts@cccp.net"